import request from "@/utils/request.js"
const api_name = "/admin/product/"

export default {
    
    //admin/product/baseSaleAttrList
    getSaleAttrList(){
        return request.get(`${api_name}/baseSaleAttrList`)
    },


    //*DELETE /admin/product/deleteSpu/{spuId}
    deleteSpu(spuId){
        return request.delete(`${api_name}/deleteSpu/${spuId}`)
    },

    //GET /admin/product/findSpuInfoByKeyword/{keyword}
    findSpuInfoByKeyword(keyword){
        return request.get(`${api_name}/findSpuInfoByKeyword/${keyword}`)
    },

    //GET /admin/product/getSpuById/{spuId}
    //获取spu基本信息 
    getSpuBaseInfo(spuId){
        return request.get(`${api_name}/getSpuById/${spuId}`)
    },

    // POST /admin/product/inner/findSpuInfoBySpuIdList
    findSpuInfoBySpuIdList(spuIdList){
        return request.post(`${api_name}/inner/findSpuInfoBySpuIdList`,spuIdList)
    },

    // // POST /admin/product/saveSpuInfo
    // saveSpuInfo(spuInfo){
    //     return request.post(`${api_name}/saveSpuInfo`,spuInfo)
    // },

    // //POST /admin/product/updateSpuInfo
    // //更改spu信息
    // updateSpuInfo(spuInfo){
    //     return request.post(`${api_name}/updateSpuInfo`,spuInfo)
    // },

      /*
    添加SPU详情信息
    POST /admin/product/saveSpuInfo
    POST /admin/product/updateSpuInfo
    */
    addUpdate(spuInfo) {
        // return request.post(`${api_name}/${spuInfo.id ? 'update' : 'save'}SpuInfo`, spuInfo)
        return request({
        url: `${api_name}/${spuInfo.id ? "update" : "save"}SpuInfo`,
        method: "POST",
        data: spuInfo
        })
    },
    
    // 获取 spuList 分页信息
    // GET /admin/product/{page}/{limit}
    getSpuList(page,limit){
        return request.get(`${api_name}/${page}/${limit}`)
    }

}